From 31b10e519c0f00b5ea56e9fc567fcdfd1b8573cb Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Fri, 4 Apr 2025 16:37:47 +0200 Subject: [PATCH] better error message for user when deleting local items we might be displaying too technical errors that the user will have no way to understand for example on macOS, we might be getting: Unknown error: 513 Signed-off-by: Matthieu Gallien --- src/libsync/propagatorjobs.cpp | 21 ++++++++------------- src/libsync/propagatorjobs.h | 2 +- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/libsync/propagatorjobs.cpp b/src/libsync/propagatorjobs.cpp index a443d8454..86086c335 100644 --- a/src/libsync/propagatorjobs.cpp +++ b/src/libsync/propagatorjobs.cpp @@ -58,18 +58,15 @@ QByteArray localFileIdFromFullId(const QByteArray &id) bool PropagateLocalRemove::removeRecursively(const QString &path) { QString absolute = propagator()->fullLocalPath(_item->_file + path); - QStringList errors; QList> deleted; const auto fileInfo = QFileInfo{absolute}; const auto parentFolderPath = fileInfo.dir().absolutePath(); const auto parentPermissionsHandler = FileSystem::FilePermissionsRestore{parentFolderPath, FileSystem::FolderPermissions::ReadWrite}; - bool success = FileSystem::removeRecursively( - absolute, - [&deleted](const QString &path, bool isDir) { - // by prepending, a folder deletion may be followed by content deletions - deleted.prepend(qMakePair(path, isDir)); - }, - &errors); + const auto success = FileSystem::removeRecursively(absolute, + [&deleted](const QString &path, bool isDir) { + // by prepending, a folder deletion may be followed by content deletions + deleted.prepend(qMakePair(path, isDir)); + }); if (!success) { // We need to delete the entries from the database now from the deleted vector. @@ -87,8 +84,6 @@ bool PropagateLocalRemove::removeRecursively(const QString &path) qCWarning(lcPropagateLocalRemove) << "Failed to delete file record from local DB" << it.first.mid(propagator()->localPath().size()); } } - - _error = errors.join(", "); } return success; } @@ -116,13 +111,13 @@ void PropagateLocalRemove::start() if (_moveToTrash && propagator()->syncOptions()._vfs->mode() != OCC::Vfs::WindowsCfApi) { if ((QDir(filename).exists() || FileSystem::fileExists(filename)) && !FileSystem::moveToTrash(filename, &removeError)) { - done(SyncFileItem::NormalError, removeError, ErrorCategory::GenericError); + done(SyncFileItem::NormalError, tr("Temporary error when removing local item removed from server."), ErrorCategory::GenericError); return; } } else { if (_item->isDirectory()) { if (QDir(filename).exists() && !removeRecursively(QString())) { - done(SyncFileItem::NormalError, _error, ErrorCategory::GenericError); + done(SyncFileItem::NormalError, tr("Temporary error when removing local item removed from server."), ErrorCategory::GenericError); return; } } else { @@ -133,7 +128,7 @@ void PropagateLocalRemove::start() const auto parentPermissionsHandler = FileSystem::FilePermissionsRestore{parentFolderPath, FileSystem::FolderPermissions::ReadWrite}; if (!FileSystem::remove(filename, &removeError)) { - done(SyncFileItem::NormalError, removeError, ErrorCategory::GenericError); + done(SyncFileItem::NormalError, tr("Temporary error when removing local item removed from server."), ErrorCategory::GenericError); return; } } diff --git a/src/libsync/propagatorjobs.h b/src/libsync/propagatorjobs.h index d5e2148c1..c7436b00a 100644 --- a/src/libsync/propagatorjobs.h +++ b/src/libsync/propagatorjobs.h @@ -44,7 +44,7 @@ public: private: bool removeRecursively(const QString &path); - QString _error; + bool _moveToTrash = false; }; -- 2.30.2